package com.yq.ylmall.product.service.impl;

import cn.hutool.core.util.StrUtil;
import com.yq.ylmall.product.service.IFileService;
import com.yq.ylmall.service.MinioService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class FileServiceImpl implements IFileService {

    private final MinioService minioService;

    @Async
    @Override
    public void removeFile(String filename) {
        if (StrUtil.isBlank(filename)) return;
        minioService.remove(filename);
    }

    @Async
    @Override
    public void removeFile(List<String> filename) {
        if (filename.isEmpty()) return;
        filename.forEach(minioService::remove);
    }

}
